package com.fancy.learncenter.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.fancy.learncenter.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.adapter.base.CustomViewHold;
import com.fancy.learncenter.bean.VitaDetailDataBean;
import com.superservice.lya.R;

import java.util.ArrayList;

/**
 * Created by hyy on 2018/2/25.
 * Explain activity as
 */

public class EducationExperienceListAdapter extends CommonRecycleViewAdapter<VitaDetailDataBean.EduListBean> {
    boolean isShow = true;

    public EducationExperienceListAdapter(Context mContext, ArrayList<VitaDetailDataBean.EduListBean> itemDatas) {
        super(mContext, R.layout.activity_education_experience_list_item, itemDatas);
    }

    public EducationExperienceListAdapter(Context mContext, ArrayList<VitaDetailDataBean.EduListBean> itemDatas, boolean isShow) {
        super(mContext, R.layout.activity_education_experience_list_item, itemDatas);
        this.isShow = isShow;
    }

    @Override
    public void bindView(CustomViewHold customViewHold, final VitaDetailDataBean.EduListBean item, int position) {

        TextView time_tv = customViewHold.getView(R.id.time_tv);
        time_tv.setText(item.getTime_interval());

        TextView education_tv = customViewHold.getView(R.id.education_tv);
        education_tv.setText(item.getProfession());

        TextView shchool_tv = customViewHold.getView(R.id.shchool_tv);
        shchool_tv.setText(item.getSchool_name());

        TextView marjor_tv = customViewHold.getView(R.id.marjor_tv);
        marjor_tv.setText(item.getDiploma_txt());


        TextView all_tv = customViewHold.getView(R.id.all_tv);
        if (item.getTime_interval().equals("1")) {
            all_tv.setText("统招");
        } else {
            all_tv.setText("非统招");
        }

        TextView edit_tv = customViewHold.getView(R.id.edit_tv);
        TextView delete_tv = customViewHold.getView(R.id.delete_tv);

        if (!isShow) {
            edit_tv.setVisibility(View.GONE);
            delete_tv.setVisibility(View.GONE);
        }


        edit_tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickCallBack.editCallBack(item);
            }
        });


        delete_tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickCallBack.deleCallBack(item);
            }
        });

    }

    private EducationExperienceListAdapter.OnClickCallBack onClickCallBack;

    public EducationExperienceListAdapter.OnClickCallBack getOnClickCallBack() {
        return onClickCallBack;
    }

    public void setOnClickCallBack(EducationExperienceListAdapter.OnClickCallBack onClickCallBack) {
        this.onClickCallBack = onClickCallBack;
    }

    public interface OnClickCallBack {
        abstract void deleCallBack(VitaDetailDataBean.EduListBean item);

        abstract void editCallBack(VitaDetailDataBean.EduListBean item);
    }
}
